<template>
  <div id="app">
    <div>
      <span>姓名：</span>
      <input v-model="name" type="text">
    </div>
    <div>
      <span>年龄：</span>
      <input v-model="age" type="text">
    </div>
    <div>
      <span>身高：</span>
      <input v-model="height" type="text">(米)
    </div>
    <div>
      <span>体重：</span>
      <input v-model="weight" type="text">(公斤)
    </div>
    <div>
      <span>病史：</span>
      <input v-model="pain" type="text">
    </div>
    <button @click="count">诊断</button>
  </div>
</template>

<script>
export default {
  components: {
    
  },
  data() {
    return {
      name:'',
      age: '',
      height: '',
      weight: '',
      pain: '',
    }
  },
  methods: {
    count() {
      const BMI = this.weight / (this.height ** 2);
      if (BMI < 18.5) {
        alert('体重过轻');
      } else if (BMI >= 18.5 && BMI < 24.9) {
        alert('体重正常');
      } else if (BMI >= 24.9 && BMI < 29.9) {
        alert('体重过重');
      } else {
        alert('肥胖');
      }
    }
  }
}
</script>

<style>
.app div {
  margin-bottom: 20px;
}
</style>
